Variational calculus